<?php
/**
 * Created by PhpStorm.
 * User: izbol
 * Date: 2017/4/25
 * Time: 13:54
 */
namespace Admin\Controller;
use think\controller;
class AuthController extends controller{
    //用户不存在的话返回登录页面
        public function _initialize() {
            if($this->cheklogin()){
                return true;
            }else{
                $this->error('你还没登陆后台！',U('Login/Login'),2);
            }
        }
        //检查用户是否存在
        public function cheklogin(){
            $this->sessions=M('blog_admin')->where(array('aid'=>$_SESSION['name']))->find();
            if(is_null(session('name'))){
                return false;
            }else{
                return true;
            }
        }
}